/*
 * Copyright : (C) 2023 Termony Technology, Inc. All Rights Reserved.
 */

#include "rk_parameters.h"
#include "ftypes.h"
#include "fmmu.h"

#ifdef LOSCFG_ARCH_ARM_AARCH64

static const struct ArmMmuRegion mmu_ranges[] =
{
    MMU_REGION_FLAT_ENTRY("DDR_2G_REGION", RK_MEMORY_MAP_ADDR, RK_MEMORY_MAP_SIZE, MT_NORMAL | MT_RW | MT_NS),
    MMU_REGION_FLAT_ENTRY("DEVICE_REGION", RK_DEVICE_MAP_ADDR, RK_DEVICE_MAP_SIZE, MT_DEVICE_NGNRE | MT_P_RW_U_RW | MT_NS),
    MMU_REGION_FLAT_ENTRY("PCIE_REGION", RK_PCIE_MAP_ADDR, RK_PCIE_MAP_SIZE, MT_DEVICE_NGNRE | MT_RW | MT_NS),

};

const uint32_t mmu_regions_size = ARRAY_SIZE(mmu_ranges);

const struct ArmMmuConfig mmu_config =
{
    .num_regions = mmu_regions_size,
    .mmu_regions = mmu_ranges,
};

#else

#define MEM_TALBE(va, size) va, ((u32)va + size - 1)

struct mem_desc platform_mem_desc[] =
{
    {MEM_TALBE(RK_MEMORY_MAP_ADDR, RK_MEMORY_MAP_SIZE), RK_MEMORY_MAP_ADDR, NORMAL_MEM},
    {MEM_TALBE(RK_DEVICE_MAP_ADDR, RK_DEVICE_MAP_SIZE), RK_DEVICE_MAP_ADDR, DEVICE_MEM}
};

const u32 platform_mem_desc_size = sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]);

#endif